<script lang="tsx" setup>
/**
 * 显示
 */
import {nextTick, ref} from "vue"
import {definePageModel, PageModel} from "../../../../index.ts"

/**
 * 页面实例
 */
const pageModelRef = ref()
const config = ref()

/**
 * 获取数据
 */
const getFormData = async () => {
  return config.value
}

/**
 * 设置数据
 */
const isRender = ref(false)
const setFormData = (value: any) => {
  console.log(value)
  isRender.value = false
  config.value = definePageModel<any>(value)
  nextTick(() => {
    isRender.value = true
  })
}

/**
 * 暴露
 */
defineExpose({
  getFormData,
  setFormData
})
</script>

<template>
  <div v-if="isRender" class="container-form">
    <PageModel ref="pageModelRef" :PageModel="config"/>
  </div>
</template>

<style lang="scss" scoped>
.container-form {
  height: 100%;
  display: flex;
}
</style>